package com.api.regression.group.addmember;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.test.context.ContextConfiguration;
import org.testng.annotations.AfterClass;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;

import com.api.test.AbstractApiTest;
import com.zyncro.api.IGroupApiService;
import com.zyncro.api.exceptions.ZyncroApiException;

@ContextConfiguration(locations = { "classpath:/group/group-context.xml" })
public class AddMemberNotParticipant extends AbstractApiTest {

	@Value("#{groupmembers['user.notParticipant'].appId}")
	private String userUrn;

	@Value("#{groupmembers['user.notParticipant'].password}")
	private String userPassword;

	@Value("#{groupmembers['group.toAdd'].urn}")
	private String groupUrn;

	@Value("#{groupmembers['user.toAdd'].appId}")
	private String memberToAddUrn;

	@BeforeClass
	public void loginUser() {

		getApi().login(userUrn, userPassword);
	}

	@Test(expectedExceptions = { ZyncroApiException.class })
	public void testAddMember() throws ZyncroApiException {

		boolean isEditor = true;
		boolean isTaskManager = true;
		boolean isInviter = true;
		boolean isCommenter = true;
		boolean isOwner = true;

		getApi().getService(IGroupApiService.class)
				.addMember(groupUrn, memberToAddUrn, isEditor, isTaskManager, isInviter, isCommenter, isOwner);
	}

	@AfterClass
	public void restoreValues() throws ZyncroApiException {

		getApi().getService(IGroupApiService.class).deleteMember(groupUrn, memberToAddUrn);
	}
}
